package com.ruoyi.system.api.wrapper;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteSysDictTypeService;
import com.ruoyi.system.api.domain.SysDictData;
import com.ruoyi.system.api.domain.SysDictType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 字典类型微服务包装服务，对微服务接口进行了封装，直接返回需要的数据。
 *
 * @author ruoyi
 * @date 2023-04-27
 */
@Component
public class RemoteSysDictTypeWrapperService extends RemoteBaseWrapperService {

    @Autowired
    private RemoteSysDictTypeService remoteSysDictTypeService;

    /**
     * 查询字典类型
     *
     * @param dictId 字典类型主键
     * @return 字典类型
     */
    public SysDictType selectSysDictTypeByDictId(Long dictId) {
        R<SysDictType> result = remoteSysDictTypeService.selectSysDictTypeByDictId(dictId, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 查询字典类型列表
     *
     * @param sysDictType 字典类型
     * @return 字典类型集合
     */
    public List<SysDictType> selectSysDictTypeList(SysDictType sysDictType) {
        R<List<SysDictType>> result = remoteSysDictTypeService.selectSysDictTypeList(sysDictType, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 新增字典类型
     *
     * @param sysDictType 字典类型
     * @return 结果
     */
    public Integer insertSysDictType(SysDictType sysDictType) {
        R<Integer> result = remoteSysDictTypeService.insertSysDictType(sysDictType, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 修改字典类型
     *
     * @param sysDictType 字典类型
     * @return 结果
     */
    public Integer updateSysDictType(SysDictType sysDictType) {
        R<Integer> result = remoteSysDictTypeService.updateSysDictType(sysDictType, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 批量删除字典类型
     *
     * @param dictIds 需要删除的字典类型主键集合
     * @return 结果
     */
    public Integer deleteSysDictTypeByDictIds(Long[] dictIds) {
        R<Integer> result = remoteSysDictTypeService.deleteSysDictTypeByDictIds(dictIds, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 根据字典类型查询字典数据
     *
     * @param dictType 字典类型
     * @return 字典数据集合信息
     */
    public List<SysDictData> selectDictDataByType(String dictType) {
        R<List<SysDictData>> result = remoteSysDictTypeService.selectDictDataByType(dictType, SecurityConstants.INNER);
        return processResult(result);
    }

    public SysDictType selectDictTypeByType(String dictType) {
        R<SysDictType> result = remoteSysDictTypeService.selectDictTypeByType(dictType, SecurityConstants.INNER);
        return processResult(result);
    }
}
